package com.iou.view;

import java.sql.SQLException;

import com.iou.database.DatabaseHelper;
import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.UI;

/**
 * Main UI class for initialization.
 */
public class IouUI extends UI implements View {

    public Navigator navigator = new Navigator(this, this);

    @Override
    protected void init(VaadinRequest request) {

        navigator.addView("LoginView", new LoginView());
        navigator.navigateTo("LoginView");

        /*
         * Database initialization
         */
        try {
            DatabaseHelper.init();
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        try {
            DatabaseHelper.buildMockData();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    @Override
    public void enter(ViewChangeEvent event) {
    }

}